﻿using System;
using ZilLion.Service.Core.DapperWrapper;
using ZilLion.Service.Core.DapperWrapper.SqlServer;
using ZilLion.Service.WeChatMall.Domain.Entitys.AppInfo;
using ZilLion.Service.WeChatMall.Domain.Repositorys.Interface.AppInfo;

namespace ZilLion.Service.WeChatMall.Domain.Repositorys.AppInfo
{
    public class AppGsRelationShipReponsitory : SqlServerRespository<AppGsRelationShipEntity>,
        IAppGsRelationShipReponsitory
    {
        public AppGsRelationShipReponsitory()
        {
            Context = new WechatMallContext();
        }

        public void RemoveRelationShipByAppId(string appid, UnitOfWork unit = null)
        {
            DapperHelper.Execute($"delete from appgsrelationship where appid=@appid", Context, unit, new {appid});
        }

        public void RemoveByGsid(long gsid, UnitOfWork unit = null)
        {
            DapperHelper.Execute($"delete from appgsrelationship where gsid=@gsid", Context, unit, new { gsid });
        }

        public void AddRelationShip(AppGsRelationShipEntity entity, UnitOfWork unit = null)
        {
            entity.UpdatedTime = DateTime.Now;
            Add(entity, unit);
        }

        public void RemoveRelationShip(AppGsRelationShipEntity entity, UnitOfWork unit = null)
        {
            entity.UpdatedTime = DateTime.Now;
            Remove(entity, unit);
        }
    }
}